<?php


abstract class BaseVisitaSocial extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_visita_social;


	
	protected $cf_trabajador_foraneo;


	
	protected $cf_estudiante;


	
	protected $cf_trabajador;


	
	protected $nombre;


	
	protected $apellido;


	
	protected $parentesco;


	
	protected $diagnostico;


	
	protected $recomendacion;


	
	protected $conclusion;


	
	protected $fecha;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpVisitaSocial()
	{

		return $this->cp_visita_social;
	}

	
	public function getCfTrabajadorForaneo()
	{

		return $this->cf_trabajador_foraneo;
	}

	
	public function getCfEstudiante()
	{

		return $this->cf_estudiante;
	}

	
	public function getCfTrabajador()
	{

		return $this->cf_trabajador;
	}

	
	public function getNombre()
	{

		return $this->nombre;
	}

	
	public function getApellido()
	{

		return $this->apellido;
	}

	
	public function getParentesco()
	{

		return $this->parentesco;
	}

	
	public function getDiagnostico()
	{

		return $this->diagnostico;
	}

	
	public function getRecomendacion()
	{

		return $this->recomendacion;
	}

	
	public function getConclusion()
	{

		return $this->conclusion;
	}

	
	public function getFecha($format = 'Y-m-d')
	{

		if ($this->fecha === null || $this->fecha === '') {
			return null;
		} elseif (!is_int($this->fecha)) {
						$ts = strtotime($this->fecha);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha] as date/time value: " . var_export($this->fecha, true));
			}
		} else {
			$ts = $this->fecha;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpVisitaSocial($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_visita_social !== $v) {
			$this->cp_visita_social = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::CP_VISITA_SOCIAL;
		}

	} 
	
	public function setCfTrabajadorForaneo($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_trabajador_foraneo !== $v) {
			$this->cf_trabajador_foraneo = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::CF_TRABAJADOR_FORANEO;
		}

	} 
	
	public function setCfEstudiante($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_estudiante !== $v) {
			$this->cf_estudiante = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::CF_ESTUDIANTE;
		}

	} 
	
	public function setCfTrabajador($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_trabajador !== $v) {
			$this->cf_trabajador = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::CF_TRABAJADOR;
		}

	} 
	
	public function setNombre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nombre !== $v) {
			$this->nombre = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::NOMBRE;
		}

	} 
	
	public function setApellido($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->apellido !== $v) {
			$this->apellido = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::APELLIDO;
		}

	} 
	
	public function setParentesco($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->parentesco !== $v) {
			$this->parentesco = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::PARENTESCO;
		}

	} 
	
	public function setDiagnostico($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->diagnostico !== $v) {
			$this->diagnostico = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::DIAGNOSTICO;
		}

	} 
	
	public function setRecomendacion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->recomendacion !== $v) {
			$this->recomendacion = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::RECOMENDACION;
		}

	} 
	
	public function setConclusion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->conclusion !== $v) {
			$this->conclusion = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::CONCLUSION;
		}

	} 
	
	public function setFecha($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha !== $ts) {
			$this->fecha = $ts;
			$this->modifiedColumns[] = VisitaSocialPeer::FECHA;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = VisitaSocialPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_visita_social = $rs->getString($startcol + 0);

			$this->cf_trabajador_foraneo = $rs->getString($startcol + 1);

			$this->cf_estudiante = $rs->getString($startcol + 2);

			$this->cf_trabajador = $rs->getString($startcol + 3);

			$this->nombre = $rs->getString($startcol + 4);

			$this->apellido = $rs->getString($startcol + 5);

			$this->parentesco = $rs->getString($startcol + 6);

			$this->diagnostico = $rs->getString($startcol + 7);

			$this->recomendacion = $rs->getString($startcol + 8);

			$this->conclusion = $rs->getString($startcol + 9);

			$this->fecha = $rs->getDate($startcol + 10, null);

			$this->estatus = $rs->getString($startcol + 11);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 12; 
		} catch (Exception $e) {
			throw new PropelException("Error populating VisitaSocial object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(VisitaSocialPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			VisitaSocialPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(VisitaSocialPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = VisitaSocialPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpVisitaSocial($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += VisitaSocialPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = VisitaSocialPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = VisitaSocialPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpVisitaSocial();
				break;
			case 1:
				return $this->getCfTrabajadorForaneo();
				break;
			case 2:
				return $this->getCfEstudiante();
				break;
			case 3:
				return $this->getCfTrabajador();
				break;
			case 4:
				return $this->getNombre();
				break;
			case 5:
				return $this->getApellido();
				break;
			case 6:
				return $this->getParentesco();
				break;
			case 7:
				return $this->getDiagnostico();
				break;
			case 8:
				return $this->getRecomendacion();
				break;
			case 9:
				return $this->getConclusion();
				break;
			case 10:
				return $this->getFecha();
				break;
			case 11:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = VisitaSocialPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpVisitaSocial(),
			$keys[1] => $this->getCfTrabajadorForaneo(),
			$keys[2] => $this->getCfEstudiante(),
			$keys[3] => $this->getCfTrabajador(),
			$keys[4] => $this->getNombre(),
			$keys[5] => $this->getApellido(),
			$keys[6] => $this->getParentesco(),
			$keys[7] => $this->getDiagnostico(),
			$keys[8] => $this->getRecomendacion(),
			$keys[9] => $this->getConclusion(),
			$keys[10] => $this->getFecha(),
			$keys[11] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = VisitaSocialPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpVisitaSocial($value);
				break;
			case 1:
				$this->setCfTrabajadorForaneo($value);
				break;
			case 2:
				$this->setCfEstudiante($value);
				break;
			case 3:
				$this->setCfTrabajador($value);
				break;
			case 4:
				$this->setNombre($value);
				break;
			case 5:
				$this->setApellido($value);
				break;
			case 6:
				$this->setParentesco($value);
				break;
			case 7:
				$this->setDiagnostico($value);
				break;
			case 8:
				$this->setRecomendacion($value);
				break;
			case 9:
				$this->setConclusion($value);
				break;
			case 10:
				$this->setFecha($value);
				break;
			case 11:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = VisitaSocialPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpVisitaSocial($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCfTrabajadorForaneo($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCfEstudiante($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCfTrabajador($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setNombre($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setApellido($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setParentesco($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setDiagnostico($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setRecomendacion($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setConclusion($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setFecha($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setEstatus($arr[$keys[11]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(VisitaSocialPeer::DATABASE_NAME);

		if ($this->isColumnModified(VisitaSocialPeer::CP_VISITA_SOCIAL)) $criteria->add(VisitaSocialPeer::CP_VISITA_SOCIAL, $this->cp_visita_social);
		if ($this->isColumnModified(VisitaSocialPeer::CF_TRABAJADOR_FORANEO)) $criteria->add(VisitaSocialPeer::CF_TRABAJADOR_FORANEO, $this->cf_trabajador_foraneo);
		if ($this->isColumnModified(VisitaSocialPeer::CF_ESTUDIANTE)) $criteria->add(VisitaSocialPeer::CF_ESTUDIANTE, $this->cf_estudiante);
		if ($this->isColumnModified(VisitaSocialPeer::CF_TRABAJADOR)) $criteria->add(VisitaSocialPeer::CF_TRABAJADOR, $this->cf_trabajador);
		if ($this->isColumnModified(VisitaSocialPeer::NOMBRE)) $criteria->add(VisitaSocialPeer::NOMBRE, $this->nombre);
		if ($this->isColumnModified(VisitaSocialPeer::APELLIDO)) $criteria->add(VisitaSocialPeer::APELLIDO, $this->apellido);
		if ($this->isColumnModified(VisitaSocialPeer::PARENTESCO)) $criteria->add(VisitaSocialPeer::PARENTESCO, $this->parentesco);
		if ($this->isColumnModified(VisitaSocialPeer::DIAGNOSTICO)) $criteria->add(VisitaSocialPeer::DIAGNOSTICO, $this->diagnostico);
		if ($this->isColumnModified(VisitaSocialPeer::RECOMENDACION)) $criteria->add(VisitaSocialPeer::RECOMENDACION, $this->recomendacion);
		if ($this->isColumnModified(VisitaSocialPeer::CONCLUSION)) $criteria->add(VisitaSocialPeer::CONCLUSION, $this->conclusion);
		if ($this->isColumnModified(VisitaSocialPeer::FECHA)) $criteria->add(VisitaSocialPeer::FECHA, $this->fecha);
		if ($this->isColumnModified(VisitaSocialPeer::ESTATUS)) $criteria->add(VisitaSocialPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(VisitaSocialPeer::DATABASE_NAME);

		$criteria->add(VisitaSocialPeer::CP_VISITA_SOCIAL, $this->cp_visita_social);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpVisitaSocial();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpVisitaSocial($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCfTrabajadorForaneo($this->cf_trabajador_foraneo);

		$copyObj->setCfEstudiante($this->cf_estudiante);

		$copyObj->setCfTrabajador($this->cf_trabajador);

		$copyObj->setNombre($this->nombre);

		$copyObj->setApellido($this->apellido);

		$copyObj->setParentesco($this->parentesco);

		$copyObj->setDiagnostico($this->diagnostico);

		$copyObj->setRecomendacion($this->recomendacion);

		$copyObj->setConclusion($this->conclusion);

		$copyObj->setFecha($this->fecha);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpVisitaSocial(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new VisitaSocialPeer();
		}
		return self::$peer;
	}

} 